<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    function* gen() {

      let a = yield 111;

      console.log(a);

      let b = yield 222;

      console.log(b);

      let c = yield 333;

      console.log(c);

      let d = yield 444;

      console.log(d);

    }

    let t = gen();
    console.log(t)

    console.log('next返回：', t.next(1)); //第一次调用next函数时，传递的参数无效，故无打印结果

    console.log('next返回：', t.next(2)); // a输出2;

    console.log('next返回：', t.next(3)); // b输出3; 

    console.log('next返回：', t.next(4)); // c输出4;

    console.log('next返回：', t.next(5)); // d输出5;

  </script>
</body>

</html>